package ${package.Entity};


import java.io.Serializable;

import com.file.system.entity.basic.WebBasic;

import javax.validation.constraints.*;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;
import com.file.system.plugin.dict.Dict;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import com.file.system.plugin.validated.SQLInjectionValidation;


/**
* ${cfg.controllerName}
*
* @author ${author}
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
<#list table.fields as field>
<#if field_index == 0 && field.customMap.engine == "MRG_MYISAM">
@MyISAM()
</#if>
</#list>
public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> implements Serializable{

    private static final long serialVersionUID = 1L;


    //新增
    public interface add extends Default{
    }

    //修改
    public interface update extends Default{
    }

<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
<#if field.keyFlag><#--生成普通字段 -->
    /**
    * ${field.comment}
    */
    @NotNull(groups = {update.class}, message = "${field.comment}不能为空")
    @Min( value = 1, message = "id长度最小1")
    private ${field.propertyType} ${field.propertyName};
</#if>
<#if !field.keyFlag><#--生成普通字段 -->
    /**
    * ${field.comment}<#if field.name?starts_with("dict")>（字典）</#if>
    */
<#if  field.customMap.data_type == "int">
    @NotNull(groups = {add.class, update.class}, message = "${field.comment}不能为空")
    @Min(value = 1, message = "${field.comment}最小1")
    <#if field.propertyName?contains("sort")>
    @Max(value = 2000, message = "${field.comment}最大2000")
    </#if>
    private ${field.propertyType} ${field.propertyName};
<#elseif  field.customMap.data_type == "bigint">
    @NotNull(groups = {add.class, update.class}, message = "${field.comment}不能为空")
    @Min(value = 1, message = "${field.comment}最小1")
    private ${field.propertyType} ${field.propertyName};
<#elseif  field.customMap.data_type == "datetime">
    @NotEmpty(groups = {add.class, update.class}, message = "${field.comment}不能为空")
    @Size(min = 1, max = 19, message = "${field.comment}长度1-19")
    @SQLInjectionValidation(fieldName = "${field.comment}")
    private String ${field.propertyName};
<#else>
    @NotEmpty(groups = {update.class,add.class}, message = "${field.comment}不能为空")
    @Size(min = 1, max = ${field.customMap.length!5}, message = "${field.comment}长度1-${field.customMap.length!5}")
    <#if field.name?starts_with("dict")>
    @Dict("${field.propertyName?replace('dict', '')?uncap_first}")
    </#if>
    @SQLInjectionValidation(fieldName = "${field.comment}")
    private ${field.propertyType} ${field.propertyName};
</#if>
</#if>
</#list>
<#------------  END 字段循环遍历  ---------->
}
